<template>
  <a-card :bordered="false">

    <div style="float: left;padding-right: 10px">
      <DingdingMessage :selectkeys02="selectedRowKeys"></DingdingMessage>
    </div>
    <div style="float: left;padding-right: 10px">
        <PhoneMessage :selectkeys01="selectedRowKeys"></PhoneMessage>
      </div>
    <div style="float: left">
      <MessageComments :selectkeys="selectedRowKeys"></MessageComments>
    </div>
<div style="height: 45px"></div>

    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a v-if="selectedRowKeys.length!=0" style="margin-left: 24px" @click="onClearSelected">清空选择</a>
      </div>
      <label style="color: red;display: flex;justify-content: center;align-content: center;margin-bottom: 20px">申请修改信息的专家若没有再次提交申请并通过申请，则该专家一律视为请假状态</label>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <span slot="professorName" slot-scope="text,record">
        <a :class="record.isLeave === 0 ? 'fontgreen' :'fontred'" disabled>{{record.professorName}}</a>
        </span>

        <span slot="isLeave" slot-scope="text,record">
        <a :class="record.isLeave === 0 ? 'fontgreen' :'fontred'" disabled>{{record.isLeave === 0?'在职':'请假'}}</a>
        </span>


        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>

        <template slot="pcaSlot" slot-scope="text">
          <div>{{ getPcaText(text) }}</div>
        </template>
        <template slot="declareCategory" slot-scope="text">
          <div>{{ initDict(text) }}</div>
        </template>

      </a-table>
    </div>

    <diyProfessorInfo-modal ref="modalForm" @ok="modalFormOk"></diyProfessorInfo-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import DiyProfessorInfoModal from './modules/DiyProfessorInfoModal'
  import { loadCategoryData } from '@/api/api'
  import {filterMultiDictText} from '@/components/dict/JDictSelectUtil'
  import Area from '@/components/_util/Area'
  import JCategorySelect from '@comp/jeecg/JCategorySelect'
  import MessageComments from "./modules/MessageComments";
  import PhoneMessage from "./modules/PhoneMessage";
  import DingdingMessage from "./modules/DingdingMessage";
  export default {
    name: "SendMessage",
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      DingdingMessage,
      PhoneMessage,
      MessageComments,
    JCategorySelect,
      DiyProfessorInfoModal
  },
  data () {
    return {
      description: '专家信息录入管理页面',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key:'rowIndex',
          width:60,
          align:"center",
          customRender:function (t,r,index) {
            return parseInt(index)+1;
          }
        },
        {
          title:'专家姓名',
          align:"center",
          // dataIndex: 'professorName',
          scopedSlots: { customRender: 'professorName' }
        },
        {
          title:'专家性别',
          align:"center",
          dataIndex: 'professorSex',
          customRender:function (text) {
            return  text=="1"?"男":"女"
          }
        },
        {
          title:'毕业院校',
          align:"center",
          dataIndex: 'professorSchool'
        },
        {
          title:'申报类别',
          align:"center",
          dataIndex: 'professorDeclareCategory',
          scopedSlots: {customRender: 'declareCategory'}
        },
        {
          title:'技术职称',
          align:"center",
          dataIndex: 'professorTitle'
          // dataIndex: 'professorTitle_dictText'
        },
        {
          title:'办公电话',
          align:"center",
          dataIndex: 'professorOfficeTel'
        },
        {
          title:'手机',
          align:"center",
          dataIndex: 'professorPhone'
        },
        {
          title:'是否请假',
          align:"center",
          scopedSlots: { customRender: 'isLeave' }
        },
      ],
      url: {
        list: "/org/diyProfessorInfo/list",
        delete: "/org/diyProfessorInfo/delete",
        deleteBatch: "/org/diyProfessorInfo/deleteBatch",
        exportXlsUrl: "/org/diyProfessorInfo/exportXls",
        importExcelUrl: "org/diyProfessorInfo/importExcel",
      },
      dictOptions:{},
      pcaData:''
    }
  },
  created() {
    this.pcaData = new Area()

  },
  computed: {
    importExcelUrl: function(){
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    },
  },
  methods: {
    initDict(text){
      let textArray=[]
      textArray= text.split(",")
      let array = []
      array = this.dictOptions.professorDeclareCategory
      let dicts = ''
      // 先判断是否为空
      if(textArray.length!=null && array.length!=null){
        for (let i = 0; i < textArray.length; i++) {
          for (let j = 0; j < array.length; j++) {
            if (textArray[i] == array[j].value){
              dicts += array[j].text
              break
            }
          }
          if(i<textArray.length-1){
            dicts += "，"
          }
        }
      }


      return dicts
    },
    /*      getPcaText(code){

            return this.pcaData.getText(code);
          },*/
    initDictConfig(){

      loadCategoryData({code:'B03'}).then((res) => {
        if (res.success) {
          // 把专家类型的值传入到dictOptions中
          this.$set(this.dictOptions, 'professorDeclareCategory', res.result)
        }
      })
    }
  }
  }
</script>
<style scoped>
  .fontgreen{
    color:green;
  }
  .fontyellow{
    color:gold;
  }
  .fontred{
    color:red;
  }
  @import '~@assets/less/common.less';
</style>